<?php
namespace Modules\Admin\Controllers;

/**
 * @name 管理员访问记录
 */
class Visitlog extends Controller {
    protected $sys_view = true;

    /**
     * @name 管理员访问记录
     */
    public function indexAction() {
    }

    /**
     * @name 访问记录数据源
     */
    public function listAction() {
        $uname = $this->getParams('uname');
        $ctrl = $this->getParams('ctrl');
        $time_from = $this->getParams('time_from');
        $time_to = $this->getParams('time_to');

        $data = (new \Modules\Admin\Model\Data\Visitlog())->getDataTable($uname, $ctrl, $time_from, $time_to);
        if (isset($data['data']) && !empty($data['data'])) {
            foreach ($data['data'] as $key => $val) {
                if ($val['uri'] == '/admin/login/check' || $val['uri'] == '/admin/login/login') {
                    $data['data'][$key]['request_info'] = json_encode(array());
                } else {
                    $data['data'][$key]['request_info'] = \Dao\Db::decrypt($val['request_info']);
                }
            }
        }
        $this->response = $data;
    }
}
